using System;
using AgileBoard.Core;
using NHibernate;

namespace Tests.AgileBoard.Infrastructure.NHibernateMaps
{
    public class DevelopmentDataLoader
    {
        public static void Run(ISession session)
        {
            var firstProject = new Project() { Name = "Dev Project" };
  
            firstProject.AddSatate(new StateTemplate(){Label = "Backlog", OrderIndex = 1});
            firstProject.AddSatate(new StateTemplate(){Label = "Analyse", OrderIndex = 2});
            firstProject.AddSatate(new StateTemplate(){Label = "Development", OrderIndex = 3});
            firstProject.AddSatate(new StateTemplate(){Label = "Testing", OrderIndex = 4});
            firstProject.AddSatate(new StateTemplate(){Label = "Deploryment", OrderIndex = 5});

            session.SaveOrUpdate(firstProject);
            
            session.SaveOrUpdate(new Project() { Name = "Dev Project" });
            session.SaveOrUpdate(new Project() { Name = "MSN caller" });

            var projector = new Project() { Name = "Projector" };

            projector.AddIteration(new Iteration
            {
                Label = "Iteration 3",
                Start = DateTime.Now,
                Finish = DateTime.Now
            });

            projector.AddIteration(new Iteration
            {
                Label = "Iteration 2",
                Start = DateTime.Now,
                Finish = DateTime.Now
            });

            projector.AddIteration(new Iteration
            {
                Label = "Iteration 1",
                Start = DateTime.Now,
                Finish = DateTime.Now
            });

            var iteration = new Iteration {
                Label = "Current",
                Start = DateTime.Now,
                Finish = DateTime.Now
            };

            var state = new State(){Label = "Backlog", OrderIndex = 1};
            state.AddStory(new Story()
                               {
                                   CreateTime = DateTime.Now,
                                   Color = "green",
                                   Name = "Lorem Ipsum",
                                   Creator = "Ion", 
                                   Size = 4,
                                   Observation = "Lorem Ipsum is simply dummy text of the printing and typesetting industry ..."
                               });
            state.AddStory(new Story()
                               {
                                   CreateTime = DateTime.Now,
                                   Color = "green",
                                   Name = "Gona stobid",
                                   Creator = "Ruslan", 
                                   Size = 4,
                                   Observation = "All the Lorem Ipsum generators on the Internet tend to repeat predefined chunks as necessary ..."
                               });

            iteration.AddState(state);
            iteration.AddState(new State(){Label = "Analyse", OrderIndex = 2});
            iteration.AddState(new State(){Label = "On Going", OrderIndex = 3});
            iteration.AddState(new State(){Label = "Testing", OrderIndex = 4});
            iteration.AddState(new State(){Label = "Deployment", OrderIndex = 5});
            iteration.AddState(new State(){Label = "Done", OrderIndex = 6});

            projector.AddIteration(iteration);

            session.SaveOrUpdate(projector);
        }
    }
}